package com.mfcxy.home.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mfcxy.entity.Comments;
import com.mfcxy.service.ICommentsService;
import com.mfcxy.tools.BackJson;

/**
 * 评论
 * @author mfcxy
 *
 */
@Controller
@RequestMapping("/comments/")
public class CommentsController {
	
	@Autowired
	private ICommentsService commentsService;
	
	/**
	 *  新增评论
	 * @param comments
	 * @return
	 */
	@ResponseBody
	@RequestMapping("add")
	public BackJson add(@ModelAttribute Comments comments) {
		commentsService.save(comments);
		Map<String, Object> map = new HashMap<>();
		map.put("comments", commentsService.getById(comments.getId()));
		BackJson bj = new BackJson();
		bj.setCode(1);
		bj.setData(map);
		return bj;
	}
}
